
package JET;

import JET.Centers.ControlCenter;
import JET.Centers.Graphics.GUICenter;
import JET.SA.SA_Menu;
import JET.graphics.jogl.GLHelper;
import JET.physics.engine.JETContext;
import javax.swing.JApplet;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

/**
 *
 * @author 057Ry
 */
public class JetApplet extends JApplet implements Constants {

    /**
     * Initialization method that will be called after the applet is loaded 
     * into the browser.
     */
    @Override
    public void init() {
        // TODO start asynchronous download of heavy resources
    }

    @Override
    public void start() {
        try {
            SwingUtilities.invokeLater(new Runnable() {

                public void run() {
                    // At the begginin there was a Word ...
                    // Najpierw decydujemy o wygladzie aplikacji, specifying Look & Feel
                    try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception ex) { ex.printStackTrace(); }

                    // First of all we need to have control over all stuff - "(...) and one to rule them all (...)"
                    ControlCenter CC = ControlCenter.getInstance();

                    // Second we need base simulation thing - an ENGINE object
                    JETContext engine = new JETContext();
                    engine.setMainBound(SCENE_START_WIDTH, SCENE_START_HEIGHT);
//                    CC.addEngine(engine, "Scene");
//                    scene.SC.injectSceneIntoJSEngine(engine);

                    // Statr building gui elements ...
                    CC.GUIC = new GUICenter();

                    appletTestPanel panel = new appletTestPanel();
                    getContentPane().add(panel);

                    // Creation of dialog frames
                    CC.GUIC.initDialogs();

//                    // Prepare scene and view
//                    SA_Menu.newProject(ControlCenter.getInstance());

                    GLHelper.initData();

                    // Prepare scene and view
                    //SA_Menu.newProject(ControlCenter.getInstance());
                    
                    try {
                        CC.loadProjectFile2("http://jet.quake2.info/cb1.xml");
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }
            });
        } catch (Exception ex) {
            ex.printStackTrace();
        }


    }
    // TODO: overwrite start(), stop() and destroy() methods

}
